﻿using System;
using Autodesk.Revit.DB;
using YJKRevitKernel.ElementSearchUtility.LinkDocumentSuite;
using YJKRevitKernel.XYZUtility;
using YJKRevitDimensionText.VerticalAutoDim.GeoModel;

namespace YJKRevitDimensionText.VerticalAutoDim.GeoTopIntersect
{
	internal class ParapetGeoTopIntersect : IGeoTopIntersectCreator
	{
		public ElementFilter Filter
		{
			get
			{
				return new ElementCategoryFilter(BuiltInCategory.OST_Walls);
			}
		}

		public Func<BaseLinkDocumentResultBean, bool> IsElementValid
		{
			get
			{
				return new Func<BaseLinkDocumentResultBean, bool>(Utility.IsValidParapetWall);
			}
		}

		public IPlanarGeo CreatePlanarGeo(Element elem, Plane pl, Transform transform)
		{
			Line wallBaseClipLine = ((elem as Wall).Location as LocationCurve).Curve as Line;
			return new ParapetGeo(elem, wallBaseClipLine, pl, transform);
		}

		public bool IsElementValidByGeo(Element elemSrc, Element elemDes)
		{
			Line line = ((elemSrc as Wall).Location as LocationCurve).Curve as Line;
			Line line2 = ((elemDes as Wall).Location as LocationCurve).Curve as Line;
			return !(line2 == null) && XYZUtilityMethod.IsParallel(line.Direction, line2.Direction);
		}
	}
}
